package com.chenyaowei.happyhub.controller;

import com.chenyaowei.happyhub.pojo.GoodsPojo.Good;
import com.chenyaowei.happyhub.pojo.wechatuser.Order;
import com.chenyaowei.happyhub.service.GoodsService.GoodService;
import com.chenyaowei.happyhub.service.GoodsService.OrderService;
import com.chenyaowei.happyhub.utils.ExcelUntil;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/admin")
public class ExcelController {
    @Resource
    GoodService goodService;
    @Resource
    OrderService orderService;
    @RequestMapping("/goodExcel")
    void goodExcel(Model model, HttpServletResponse response) throws IOException {
        List<Good> goodList = goodService.selectGoods();
        ExcelUntil.writeExcel(response,goodList);
    }
    @RequestMapping("/orderExcel")
    void orderExcel(Model model, HttpServletResponse response) throws IOException {
        List<Order> orderList = orderService.selectAllOrder();
        ExcelUntil.writeExcel(response,orderList);
    }
}
